UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'A1MgY3sOWot5+GexFSq+ErY0wjX/Gi0bIMdywkaj34w='
WHERE
key_id = 'a2c8b60e145826ba4f1d8d23876b51a8f0fb0e14c0e3aa23c2548bdbc1dac1fe'
AND (
token = 'A1MgY3sOWot5+GexFSq+ErY0wjX/Gi0bIMdywkaj34w='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)