UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ZsRJy1kV12YLAcKJ6xVuFkoP4TZhY33cdduUxgxYiMk='
WHERE
key_id = 'd9798f4c97707db1b84317955565efa8bba3afd80995575998cb60d5224decd1'
AND (
token = 'ZsRJy1kV12YLAcKJ6xVuFkoP4TZhY33cdduUxgxYiMk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)