UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Z7LiLq0Blb44+1vplOUlP/wK74Mkb61SHEoWpMKVC+w='
WHERE
key_id = '31ac6c87208308fa887540bf80a2b07795eee1c6cabc9f0e3b5331733c5d654c'
AND (
token = 'Z7LiLq0Blb44+1vplOUlP/wK74Mkb61SHEoWpMKVC+w='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)