UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'dDRfwCm0rJRwI+fcOK5ahWJ0B21vPa4V7MG6LF1n34o='
WHERE
key_id = 'a8587e9c024b5a0f383210764a5f03495c8813f6b453a1532939ad891ab454ec'
AND (
token = 'dDRfwCm0rJRwI+fcOK5ahWJ0B21vPa4V7MG6LF1n34o='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)